
/**
 * 生成图表
 * @param list
 */
function genChart(map) {
    // 获取x,y数据
    xArr = new Array();
    series = new Array();
    legendData = new Array();
    for (let key in map) {
        legendData.push(key);
        value = map[key];
        // y轴参数
        yArr = new Array();
        xArr.length = 0;
        value.forEach(item =>{
            xArr.push(item.updateDate);
            yArr.push(item.attackNum)
        })
        serie = {
            "name": key,
            "type": "line",
            "data": yArr
        }
        series.push(serie);
    }
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};
    option = {
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            top: 30,
            type: 'scroll',
            data: legendData
        },
        toolbox: {
            show: true,
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                dataView: {readOnly: false},
                magicType: {type: ['line', 'bar']},
                restore: {},
                saveAsImage: {}
            }
        },
        xAxis: {
            name: '更新时间',
            type: 'category',
            data: xArr
        },
        yAxis: {
            name: '战力值',
            type: 'value'
        },
        series: series
    };
    myChart.setOption(option, true);
}

function getGangList(areaId) {
    $.ajax({
        url: "gang/cur/"+areaId,
        type: "get",
        success: function (result) {
            var list = result.data;
            $("#gangList li").remove();
            list.forEach(item => {
                // 添加节点
                fun = "javascript:getChartData('" + areaId + "','"+ item.gangName +"');";
                var li = '<li title="战力：' + item.gangAttackNum + '">' +
                    '<a href="' + fun + '">' + item.gangName + '</a>' +
                    '</li>';
                $("#gangList").append(li);
            })

        }
    })
}